import { getStore, setStore,removeStore } from '@/util/store'

const common = {

    state: {
        screen: -1,
        theme: getStore({ name: 'theme' }) || '#409EFF',
        themeName: getStore({ name: 'themeName' }) || 'default',
        lockPasswd: getStore({ name: 'lockPasswd' }) || '',
        isLock: getStore({ name: 'isLock' }) || false,
        lockPath:getStore({ name: 'lockPath' }) || '/setting/globaStyle',
    },
    actions: {},
    mutations: {
        SET_THEME: (state, color) => {
            state.theme = color
            setStore({
                name: 'theme',
                content: state.theme
            })
        },
        SET_SCREEN: (state, screen) => {
            state.screen = screen
        },
        SET_THEME_NAME: (state, themeName) => {
            state.themeName = themeName
            setStore({
                name: 'themeName',
                content: state.themeName
            })
        },
        SET_LOCK_PASSWD: (state, lockPasswd) => {
            state.lockPasswd = lockPasswd
            setStore({
                name: 'lockPasswd',
                content: state.lockPasswd,
                type: 'session'
            })
        },
        SET_LOCK: (state) => {
            state.isLock = true
            setStore({
                name: 'isLock',
                content: state.isLock,
                type: 'session'
            })
        },
        CLEAR_LOCK: (state) => {
            state.isLock = false
            state.lockPasswd = ''
            removeStore({
                name: 'lockPasswd',
                type:'session'
            })
            removeStore({
                name: 'isLock',
                type:'session'
                
            })
        },
        SET_LOCKPATH: (state,lockPath) => {
            state.lockPath = lockPath
            setStore({
                name: 'lockPath',
                content: state.lockPath,
                type: 'session'
            })
        },
    }
}
export default common
